<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Questions | Show</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
    <script type="text/javascript" src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
    <script src="/static/jquery.twbsPagination.js"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" />
    <link rel="shortcut icon" type="image/png" href="/static/img/favicon.png">
    <link rel="stylesheet" type="text/css" href="/static/main.css" />
    <style>
        form {
        display: inline-block;
        position: relative;
        }
        form input {
        padding-right: 4.6em;
        height: 34px;
        width:100%;
        }
        form button {
        position: absolute;
        top: 0;
        right: 0;
        width: 4.4em;
    }
    </style>
  </head>
  <body>
    <nav class="navbar navbar-default navbar-static-top navbar-inverse">
      <div class="container">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="/">问答</a>
        </div>
        <div id="navbar" class="collapse navbar-collapse">
        <ul class="nav navbar-nav navbar-right">
          {{if not .userId }}
          <li>
            <a href="/login?next=/chat"><i class="fa fa-commenting-o" aria-hidden="true"></i>&nbsp; 聊天</a>
          </li>
          {{else}}
          <li>
            <a href="/chat"><i class="fa fa-commenting-o" aria-hidden="true"></i>&nbsp; 聊天</a>
          </li>
          {{end}}
          <li>
            <a href="/categories"> 分类</a>
          </li>
          <li>
            <a href="/rank"> 用户榜</a>
          </li>
          <li>
            <a href="/"> 问题</a>
          </li>
          {{if .userId }}
              {{if eq .userId 1}}
              <li class="dropdown">
                  <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">欢迎 {{.user}} <span class="caret"></span></a>
                  <ul class="dropdown-menu">
                      <li><a href="/admin"><i class="fa fa-user"></i> 管理</a></li>
                      <li><a href="/logout"><i class="fa fa-sign-out"></i> 登出</a></li>
                  </ul>
              </li>
              {{else}}
              <li class="dropdown">
                  <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">欢迎 {{.user}} <span class="caret"></span></a>
                  <ul class="dropdown-menu">
                      <li><a href="/profile/{{.userId}}"><i class="fa fa-user"></i> 个人信息</a></li>
                      <li><a href="/logout"><i class="fa fa-sign-out"></i> 登出</a></li>
                  </ul>
              </li>
              {{end}}
          {{else}}
          <li>
            <a href="/login"> 登录</a>
          </li>
          <li>
            <a href="/signup"> 注册</a>
          </li>
          {{end}}
        </ul>
      </div>
    </nav>

    <div class="container">
      <div class="row">
        <div class="col-lg-8 col-lg-offset-2">
          {{if .user}}
          <a href="/create" class="btn btn-success"><i class="fa fa-plus"></i> 提问</a>

          {{ else }}
          <a href="/login" class="btn btn-success"><i class="fa fa-plus"></i> 提问</a>
          {{ end }}


      <form action="/search" method="get" class="form-inline" style="float:right">
        <div class="form-group">
          <input type="text" name="q" class="col-xs-8 form-control" placeholder="Search ..." style="height:34px">
            <button type="submit" class="btn btn-success"><i class="fa fa-search"></i></button>
        </div>
      </form>
      </div>
      </div>
    </div>

      <br>



<div class="container">
  <div class="row">
    <div class="col-lg-8 col-lg-offset-2">

      <a href="/" class="btn btn-link">所有问题</a>
      <a href="/unsolved" class="btn btn-link">未解决</a>
      <a href="/solved" class="btn btn-link">已解决</a>
      <a href="/viewed" class="btn btn-link">浏览最多</a>
      <a href="/oldest" class="btn btn-link">历史问题</a>
      <br><br>
{{range .questions}}
{{$tags := .Tags}}
    <div class="list-group">
      <div class="list-group-item list-group-item-action flex-column align-items-start">
        <div class="d-flex w-100 justify-content-between">
          <h4 class="mb-1"><b><a href="/show/{{.Id}}">{{.Title}}</a></b>
            <small>asked {{.CreatedAt.Format "2006-01-02 15:04"}} by <b><a href='/profile/{{.User.Id}}'>{{.User.Username}}</a></b>
              </b></small></h4>
          <hr>
          <p class="mb-1">{{.Body}}</p><br>
          {{range $tag := $tags}}
            <a href="/tags/{{$tag.Name}}" class="btn btn-xs btn-primary">{{$tag.Name}}</a>
          {{end}}

          <br><br>
            <i class="fa fa-eye" aria-hidden="true" title="Views"> {{.Views }}</i>&ensp;
            <i class="fa fa-comment" aria-hidden="true" title="Answers"> {{.AnswerCount}}</i>&ensp;
            <i class="fa fa-thumbs-up" aria-hidden="true" title="Likes"> {{.Likes}}</i>
            {{if .AcceptedAnswer}}
            <span class="badge pull-right">Solved</span>
            {{else}}
              {{end}}
        </div>
      </div>
    </div>

{{end}}
<ul id="questions" class="pagination-sm pull-right"></ul>
        </div>

      </div>
    </div>

</div>
<script type="text/javascript">
    $('#questions').twbsPagination({
      totalPages: {{.totalPages}},
      visiblePages: 4,
      startPage: 1,
      pageVariable: 'page',
      href: true,
      defaultHref: '/solved?page=',
    });
  </script>

  </body>
</html>
